<!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
<stack>
<name>in.03</name>
<id>-1</id>
<cardCount>2</cardCount>
<cardID>17566</cardID>
<listID>2288</listID>
<cantModify><false /></cantModify>
<cantDelete><false /></cantDelete>
<cantAbort><false /></cantAbort>
<cardSize>
<width>512</width>
<height>208</height>
</cardSize>
<script>-- modified stack script for stack browsing, based originally on-- Free Text v.1 ... not thoroughly checked or tested yet!!!on openStackinitGlobals -- set up many things for this stackpass openStackend openStackon closeStack-- close out files, vars, empty fields nicelyset cursor to watchlock screenrepeat for the number of cards -- close all database filesif the short name of this bkgnd is "BrowserBg" then closeDatabasego to next cardend repeatshow menuBarpass closeStackend closeStackon closeDatabase-- called before opening a file as well as when leaving the stackget openCloseFiles (getTextFileRefNum(), getKeyFileRefNum(),¬getPtrFileRefNum())if not (getSubsetHandle(1) = 0 or getSubsetHandle(1) = empty) thenget zbrowser ("RELEASESUBSET", getSubsetHandle(1))setSubsetHandle 1,0end ifif not (getSubsetHandle(2) = 0 or getSubsetHandle(2) = empty) thenget zbrowser ("RELEASESUBSET", getSubsetHandle(2))setSubsetHandle 2,0end ifput empty into field "FTVars"put empty into field "Index1"put empty into field "Index2"put empty into field "Context"put empty into field "Database Name"hide field "searchPattern1"hide field "searchPattern2"hide bg button "and subsets"hide bg button "or subsets"hide bg button "not subset 1"hide bg button "not subset 2"hide bg button "fill subset 1"hide bg button "fill subset 2"end closeDatabaseon initGlobals-- initialize many things here for the stack to use globallyglobal indexLines, contextLines, maxIndexSampleCount,¬indexCountWidth, indexKeyWidth, contextLineLength, contextWordOffset,¬maxContextLinesSkipped, textChunkSize, textOffset, errorCount,¬contextGutterWidth, whichSubsetput 7 into indexLines -- hold this many lines in Index fieldsput 7 into contextLines -- hold this many lines in Context fieldput 100 into maxIndexSampleCount -- sample size during subset countsput 5 into indexCountWidth -- this many digits of count info for Indexput 28 into indexKeyWidth -- this many letters of Index wordsput 80 into contextLineLength -- this many letters of Contextput 35 into contextWordOffset -- key word starts in this columnput 100 into maxContextLinesSkipped-- make a line of dots after this many lines in subset are skippedput 25000 into textChunkSize -- grab this much for text fieldput 1 into textOffset -- put key word this far into text chunkput 0 into errorCount -- initialize counter to control error displayput 0 into contextGutterWidth -- spaces before key wordput 1 into whichSubset -- identify which subset, 1 or 2, is being usedend initGlobalson checkOpenDatabase-- test to catch attempt to operate without an open indexed file;-- try turning it into an "Open Database" request if so!if (getTextFileRefNum() = 0 or getTextFileRefNum() = empty) thenbeepanswer "No database open!"exit to HyperCardend ifend checkOpenDatabasefunction clickedLineNum-- compute which line number of the field got the clickreturn 1 + trunc((item 2 of the clickLoc - (item 2 of (the rectangle¬of the target))) / (the textheight of the target))end clickedLineNumfunction clickedOnLeftHalf-- see if click was on left half of the button, for AND and OR subsetsput item 1 of the clickLoc into clickXput ((item 1 of the rect of the target) + (item 3 of the rect of the¬target)) / 2 into midPointXreturn (clickX < midPointX)end clickedOnLeftHalfon browseIndex1-- fill Index field #1global indexLines, maxIndexSampleCount, indexCountWidth, indexKeyWidthget zbrowser ("INDEX", getwordnum1(), indexLines,¬maxIndexSampleCount, indexCountWidth, indexKeyWidth,¬getKeyFileRefNum(), getPtrFileRefNum(), getSubsetHandle(1))put line 1 to indexLines of It into field "Index1"setInstanceList1 (line (indexLines+1) to (2*indexLines) of It)end browseIndex1on browseIndex2-- fill Index field #2global indexLines, maxIndexSampleCount, indexCountWidth, indexKeyWidthget zbrowser ("INDEX", getwordnum2(), indexLines,¬maxIndexSampleCount, indexCountWidth, indexKeyWidth,¬getKeyFileRefNum(), getPtrFileRefNum(), getSubsetHandle(2))put line 1 to indexLines of It into field "Index2"setInstanceList2 (line (indexLines+1) to (2*indexLines) of It)end browseIndex2on browseContext lineOffset-- fill the Context fieldglobal contextLines, contextLineLength, contextWordOffset,¬maxContextLinesSkipped, contextGutterWidth, whichSubsetget zbrowser ("CONTEXT", getInstanceNum(), contextLines,¬lineOffset, contextLineLength, contextWordOffset,¬maxContextLinesSkipped, contextGutterWidth, getPtrFileRefNum(),¬getTextFileRefNum(), getSubsetHandle(whichSubset))put line 1 to contextLines of It into field ContextsetTextPtrList (line (contextLines+1) to (2*contextLines) of It)end browseContext---- the remaining functions set and fetch values of various useful-- quantities; do it this way to hide the details of how things are-- stored....--function getTextFileRefNumreturn line 1 of field FTVarsend getTextFileRefNumon setTextFileRefNum refNumput refNum into line 1 of field FTVarsend setTextFileRefNumfunction getKeyFileRefNumreturn line 2 of field FTVarsend getKeyFileRefNumon setKeyFileRefNum refNumput refNum into line 2 of field FTVarsend setKeyFileRefNumfunction getPtrFileRefNumreturn line 3 of field FTVarsend getPtrFileRefNumon setPtrFileRefNum refNumput refNum into line 3 of field FTVarsend setPtrFileRefNumfunction getWordNum1return line 4 of field FTVarsend getWordNum1on setWordNum1 wordNumput wordNum into line 4 of field FTVarsend setWordNum1function getWordNum2return line 5 of field FTVarsend getWordNum2on setWordNum2 wordNumput wordNum into line 5 of field FTVarsend setWordNum2function getInstanceNumreturn line 6 of field FTVarsend getInstanceNumon setInstanceNum instanceNumput instanceNum into line 6 of field FTVarsend setInstanceNumfunction getTextStartreturn line 7 of field FTVarsend getTextStarton setTextStart textStartput textStart into line 7 of field FTVarsend setTextStartfunction getTextTargetreturn line 8 of field FTVarsend getTextTargeton setTextTarget textTargetput textTarget into line 8 of field FTVarsend setTextTargetfunction getTextEndreturn line 9 of field FTVarsend getTextEndon setTextEnd textEndput textEnd into line 9 of field FTVarsend setTextEndfunction getSubsetHandle subsetNumberreturn line 9+subsetNumber of field FTVarsend getSubsetHandleon setSubsetHandle subsetNumber, handleput handle into line 9+subsetNumber of field FTVarsend setSubsetHandlefunction getNeighborhoodSizereturn line 12 of field FTVarsend getNeighborhoodSizeon setNeighborhoodSize sizeput size into line 12 of field FTVarsend setNeighborhoodSize-- lines 13 through 19 of field FTVars are currently unusedfunction getInstanceList1item instanceNumreturn line 19+instanceNum of field FTVarsend getInstanceList1itemon setInstanceList1 instanceListglobal indexLinesput instanceList into line 20 to 19+indexLines of field FTVarsend setInstanceList1function getInstanceList2item instanceNumglobal indexLinesreturn line 19+indexLines+instanceNum of field FTVarsend getInstanceList2itemon setInstanceList2 instanceListglobal indexLinesput instanceList into line 20+indexLInes to 19+2*indexLines¬of field FTVarsend setInstanceList2function getTextPtrListInstanceItem itemNumglobal indexLines, contextLinesreturn word 1 of line 19+2*indexLines+itemNum of field FTVarsend getTextPtrListInstanceItemfunction getTextPtrListPtrItem itemNumglobal indexLines, contextLinesreturn word 2 of line 19+2*indexLines+itemNum of field FTVarsend getTextPtrListPtrItemon setTextPtrList textPtrListglobal indexLines, contextLinesput textPtrList into line 20+2*indexLInes to 19+2*indexLines¬+contextLines of field FTVarsend setTextPtrList</script>